<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('Businessset/pricing_tactics_list/')}">服务策略单管理</a></li>
        <li class="active"><a href="#')">服务策略单添加</a></li>
    </ul>

    <form  id="myform2"  method="post" class="form-horizontal js-ajax-form" action="{:U('Businessset/pricing_tactics_add')}"  method="post">

        <fieldset>
            <input type="hidden" name="pid" value="{$data.pid}">
            <div class="control-group">
                <label class="control-label">城市:</label>
                <div class="controls">
                    <select onchange="CityChanged();" id="city"  name="city">
                        <option value="">==请选择省==</option>
                        <volist name="province_data" id="vo">
                            <option value="{$vo.id}">{$vo.name}</option>
                        </volist>
                    </select>
                    <select name="city_id" id="city_id">

                    </select>
                </div>
                <!-- 里程费配置 -->
                <h4 style="color: #f50">里程费配置</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addmileage" onClick="add_mileage_Div();" />
                <div id="div_mileage">
                    <div class="control-group">
                        <label class="control-label">标题:</label>
                        <div class="controls">
                            <input name="mileage[1][title]" type="text" required/>
                        </div>
                        <label class="control-label">公里:</label>
                        <div class="controls">
                            <input name="mileage[1][kilometre]" type="text" required/>
                        </div>
                        <label class="control-label">金额:</label>
                        <div class="controls">
                            <input name="mileage[1][money]" type="text"  required/>
                        </div>
                        <label class="control-label">金额标题:</label>
                        <div class="controls">
                            <input name="mileage[1][money_title]" type="text" required/>
                        </div>
                        <label class="control-label">每公里金额:</label>
                        <div class="controls">
                            <input name="mileage[1][pricePer]" type="text"  required/>
                        </div>
                    </div>
                </div>
                <!-- 排队费用配置 -->
                <h4 style="color: #f50">排队费用配置</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addline_up" onClick="add_line_up_Div();" />
                <div id="div_line_up">
                    <div class="control-group">
                        <label class="control-label">标题:</label>
                        <div class="controls">
                            <input name="line_up[1][title]" type="text"  required/>
                        </div>
                        <label class="control-label">时长:</label>
                        <div class="controls">
                            <input name="line_up[1][timemin]" type="text" required/>
                        </div>
                        <label class="control-label">金额:</label>
                        <div class="controls">
                            <input name="line_up[1][money]" type="text" required/>
                        </div>
                        <label class="control-label">金额标题:</label>
                        <div class="controls">
                            <input name="line_up[1][money_title]" type="text"  required/>
                        </div>
                        <label class="control-label">每小时金额:</label>
                        <div class="controls">
                            <input name="line_up[1][pricePer]" type="text" required />
                        </div>
                    </div>
                </div>

                <!-- 夜间加价配置 -->
                <h4 style="color: #f50">夜间加价配置</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addnight" onClick="add_night_Div();" />
                <div id="div_night">
                    <div class="control-group">
                        <label class="control-label">标题:</label>
                        <div class="controls">
                            <input name="night[1][title]" type="text"  required/>
                        </div>
                        <label class="control-label">开始时间:</label>
                        <div class="controls">
                            <input name="night[1][startTime]" type="text" required/>
                        </div>
                        <label class="control-label">结束时间:</label>
                        <div class="controls">
                            <input name="night[1][endTime]" type="text" required/>
                        </div>
                        <label class="control-label">每单加价金额:</label>
                        <div class="controls">
                            <input name="night[1][addMoney]" type="text" required />
                        </div>
                        <label class="control-label">金额描述:</label>
                        <div class="controls">
                            <input name="night[1][money_title]" type="text"  required/>
                        </div>
                    </div>
                </div>

                <!-- 临时加价配置 -->
                <h4 style="color: #f50">临时加价配置</h4>
                <div id="div_temporary">
                    <div class="control-group">
                        <label class="control-label">加价金额:</label>
                        <div class="controls">
                            <input name="temporary[addtimes]" type="text"  required/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">加价原因:</label>
                        <div class="controls">
                            <textarea name="temporary[addtimes_reson]" cols="20" rows="5"></textarea>
                        </div>
                    </div>
                </div>

                <!-- 起步价冗余字段 -->
                <h4 style="color: #f50">起步价冗余字段</h4>
                <input type="button"  class="btn btn-primary" value="增加" id="addstarting_price" onClick="add_starting_price_Div();" />
                <div id="div_is_starting_price">
                    <div class="control-group">
                        <label class="control-label">起步公里数:</label>
                        <div class="controls">
                            <input name="is_starting_price[1][mileageKilometre]" type="text"  required/>公里
                        </div>
                        <label class="control-label">金额:</label>
                        <div class="controls">
                            <input name="is_starting_price[1][mileageMoney]" type="text" required/>元
                        </div>
                        <label class="control-label">起步时间:</label>
                        <div class="controls">
                            <input name="is_starting_price[1][lineTime]" type="text"  required/>分钟
                        </div>
                        <label class="control-label">金额:</label>
                        <div class="controls">
                            <input name="is_starting_price[1][lineKoney]" type="text" required/>元
                        </div>
                    </div>
                </div>
            </div>

        </fieldset>
        <div class="form-actions">
            <button type="submit" class="btn btn-primary js-ajax-submit">{:L('SAVE')}</button>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
        var mileage_count = 2;
        function add_mileage_Div(){
            var div ="新增：<div class=\"control-group\">"+
                                "<label class=\"control-label\">标题:</label>"+
                                "<div class=\"controls\">"+
                                "<input name=\"mileage["+mileage_count+"][title]\" type=\"text\"/ required>"+
                                "</div>"+
                                "<label class=\"control-label\">公里:</label>"+
                                "<div class=\"controls\">"+
                                "<input name=\"mileage["+mileage_count+"][kilometre]\" type=\"text\" required/>"+
                                "</div>"+
                                "<label class=\"control-label\">金额:</label>"+
                                "<div class=\"controls\">"+
                                "<input name=\"mileage["+mileage_count+"][money]\" type=\"text\" required/>"+
                                "</div>"+
                                "<label class=\"control-label\">金额标题:</label>"+
                                "<div class=\"controls\">"+
                                "<input name=\"mileage["+mileage_count+"][money_title]\" type=\"text\"  required/>"+
                                "</div>"+
                                "<label class=\"control-label\">每公里金额:</label>"+
                                "<div class=\"controls\">"+
                                "<input name=\"mileage["+mileage_count+"][pricePer]\" type=\"text\" required/>"+
                                "</div>"+
                            "</div>";

            $('#div_mileage').append(div);
            mileage_count++;
        };

        var line_up_count = 2;
        function add_line_up_Div(){
            var div ="新增：<div class=\"control-group\">"+
                    "<label class=\"control-label\">标题:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"line_up["+line_up_count+"][title]\" type=\"text\" required/>"+
                    "</div>"+
                    "<label class=\"control-label\">时长:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"line_up["+line_up_count+"][timemin]\" type=\"text\" required/>"+
                    "</div>"+
                    "<label class=\"control-label\">金额:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"line_up["+line_up_count+"][money]\" type=\"text\" required/>"+
                    "</div>"+
                    "<label class=\"control-label\">金额标题:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"line_up["+line_up_count+"][money_title]\" type=\"text\"  required/>"+
                    "</div>"+
                    "<label class=\"control-label\">每公里金额:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"line_up["+line_up_count+"][pricePer]\" type=\"text\" required/>"+
                    "</div>"+
                    "</div>";

            $('#div_line_up').append(div);
            line_up_count++;
        };

        //夜间加价
        var night_count = 2;
        function add_night_Div(){
            var div ="新增：<div class=\"control-group\">"+
                    "<label class=\"control-label\">标题:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"night["+night_count+"][title]\" type=\"text\" required/>"+
                    "</div>"+
                    "<label class=\"control-label\">开始时间:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"night["+night_count+"][startTime]\" type=\"text\" required/>"+
                    "</div>"+
                    "<label class=\"control-label\">结束时间:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"night["+night_count+"][endTime]\" type=\"text\" required/>"+
                    "</div>"+
                    "<label class=\"control-label\">每单加价金额:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"night["+night_count+"][addMoney]\" type=\"text\"  required/>"+
                    "</div>"+
                    "<label class=\"control-label\">金额描述:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"night["+night_count+"][money_title]\" type=\"text\" required/>"+
                    "</div>"+
                    "</div>";

            $('#div_night').append(div);
            night_count++;
        };

        //夜间加价
        var starting_price_count = 2;
        function add_starting_price_Div(){
            var div ="新增：<div class=\"control-group\">"+
                    "<label class=\"control-label\">起步公里数:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"is_starting_price["+starting_price_count+"][mileageKilometre]\" type=\"text\" required/>公里"+
                    "</div>"+
                    "<label class=\"control-label\">金额:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"is_starting_price["+starting_price_count+"][mileageMoney]\" type=\"text\" required/>元"+
                    "</div>"+
                    "<label class=\"control-label\">起步时间:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"is_starting_price["+starting_price_count+"][lineTime]\" type=\"text\" required/>分钟"+
                    "</div>"+
                    "<label class=\"control-label\">金额:</label>"+
                    "<div class=\"controls\">"+
                    "<input name=\"is_starting_price["+starting_price_count+"][lineKoney]\" type=\"text\"  required/>元"+
                    "</div>"+
                    "</div>";

            $('#div_is_starting_price').append(div);
            starting_price_count++;
        };
    function CityChanged(province_id){

        $.ajax({
            url:"{:U('Operation/location_api')}",
            data:"province_id="+$("#city").val(),
            dataType:"JSON",
            success:function(ret){

                cmbAddOption(ret.retValue);
            }
        });
    }

    function cmbAddOption(ret)
    {
        $("#city_id").empty();
        var opetion = null;
        for(var i =0; i<ret.length;i++){
            opetion+= '<option value="'+ret[i].id+'">'+ret[i].city+'</option>';
        }
        $("#city_id").append(opetion);
    }


</script>
</body>
</html>